// https://leetcode.cn/problems/uOAnQW/description/
var maxmiumScore = function (cards, cnt) {
    let odd = [0], even = [0]
    cards.sort((a, b) => b - a)
    for (let i = 0; i < cards.length; i++) {
        if (cards[i] % 2) {
            odd.push(cards[i] + odd[odd.length - 1])
        } else {
            even.push(cards[i] + even[even.length - 1])
        }
    }
     //奇数的个数（偶的）
    let max = 0
    for (let k= 0; k < odd.length; k += 2) {
       if(cnt-k>=0&&cnt-k<even.length){
        max = Math.max(max,even[cnt-k]+odd[k])
       }
    }
    return max
};
console.log(maxmiumScore([2,2,2,2], 3))